/**
 * Demonstrates a range of Button options the framework offers out of the box
 */
Ext.define('cloud.view.homepic.AdpicAdd', {
    extend: 'Ext.Panel',
    xtype: 'adpicAdd',
    requires: [
        'Ext.form.Panel',
        'Ext.form.FieldSet',
        'Ext.field.Select',
        'Ext.ux.Fileup',
        'Ext.Img'
    ],
    config: {
        title:'首页广告添加',
        items:[
            {
                xtype: 'toolbar',
                docked: 'bottom',
                layout: {
                    type: 'hbox',
                    pack: 'end'
                },
                items: [
                    {
                        id: 'adpic_submit',
                        iconMask: true,
                        scope: this,
                        cls:'x-button2',
                        text: '提交',
                        style: 'float:right'
                    }
                ]
            },
            {
            xtype:'fieldset',
            title: '添加广告',
            items: [
                {
                    xtype:'selectfield',
                    label:'选择地区',
                    name:'cadid',
                    store:'AreaAllFindStore',
                    id:'adpic_cadid',
                    displayField: 'name',
                    valueField: 'cadid',
                    listeners:{
                        initialize: function () {
                            var caid=localStorage.getItem('caid');
                            var store = Ext.getStore('AreaAllFindStore');
                            store.load({params: {caid: caid}});
                        },
                        change: function () {
                            var cadid=Ext.getCmp('adpic_cadid').getValue();
                            var store = Ext.getStore('ProductAllFullFindStore');
                            store.load({params: {cadid: cadid}});
                        }
                    }
                },
                {
                    xtype:'selectfield',
                    label:'连接的产品',
                    name:'linkProduct',
                    id:'adpic_linkProduct',
                    displayField: 'name',
                    valueField: 'cpid',
                    store:'ProductAllFullFindStore',
                    listeners:{
                        initialize: function () {
                            var cadid=Ext.getCmp('adpic_cadid').getValue();
                            var store = Ext.getStore('ProductAllFullFindStore');
                            store.load({params: {cadid: cadid}});
                        }
                    }
                },
                {
                    xtype:'textfield',
                    label:'广告名',
                    name:'name',
                    id:'adpic_name'
                },
                {
                    xtype:'textfield',
                    label:'广告地址',
                    name:'picUrl',
                    id:'adpic_add_picUrl',
                    hidden:true,
                    readOnly:true
                },
                {
                    xtype:'textareafield',
                    label:'说明',
                    name:'explain',
                    id:'adpic_explain'
                },
                {
                    xtype:'selectfield',
                    label:'排序',
                    name:'display',
                    id:'adpic_display',
                    options: [
                        {text: '1',  value: '1'},
                        {text: '2', value: '2'},
                        {text: '3',  value: '3'},
                        {text: '4',  value: '4'},
                        {text: '5', value: '5'},
                        {text: '6',  value: '6'},
                        {text: '7',  value: '7'},
                        {text: '8', value: '8'},
                        {text: '9',  value: '9'},
                        {text: '10',  value: '10'}
                    ]
                },
                {
                    id:'adpic_upload',
                    style:'margin:10px',
                    html:'<input id="adpic_img"  type="file" onchange="previewImage(this)"  />'
                },
                {
                    id:'adpic_showImage',
                    html:'<div id="preview"><img id="imghead" width=150 height=150 src=""></div>'
                }
            ]
        }]
    }
});